﻿#region File Description
/****************************************************************************
*                                                                           *
* Options Menu Screen.                                                      *
*                                                                           *
* Copyright (c) Ionescu Marius. All rights reserved(2010).                  *
*                                                                           *
****************************************************************************/
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace XNA_FRAMEWORK
{
    class XNAOptionsMenuScreen : XNAMenuScreen
    {
        #region Fields

        XNAMenuEntry ungulateMenuEntry;
        XNAMenuEntry languageMenuEntry;
        XNAMenuEntry fullScreenMenuEntry;
        XNAMenuEntry speedMenuEntry;

        enum Ungulate
        {
            BactrianCamel,
            Dromedary,
            Llama,
        }

        static Ungulate currentUngulate = Ungulate.Dromedary;

        static string[] languages = { "English", "French", "Italian" };
        static int currentLanguage = 0;
        static bool fullscreen = true;
        static int speed = 15;

        #endregion

        #region Initialization

        public XNAOptionsMenuScreen()
            : base("Options")
        {
            ungulateMenuEntry = new XNAMenuEntry(string.Empty);
            languageMenuEntry = new XNAMenuEntry(string.Empty);
            fullScreenMenuEntry = new XNAMenuEntry(string.Empty);
            speedMenuEntry = new XNAMenuEntry(string.Empty);

            SetMenuEntryText();

            XNAMenuEntry backMenuEntry = new XNAMenuEntry("Back");

            ungulateMenuEntry.Selected += UngulateMenuEntrySelected;
            languageMenuEntry.Selected += LanguageMenuEntrySelected;
            fullScreenMenuEntry.Selected += fullScreenMenuEntrySelected;
            speedMenuEntry.Selected += speedMenuEntrySelected;
            backMenuEntry.Selected += OnCancel;

            MenuEntries.Add(ungulateMenuEntry);
            MenuEntries.Add(languageMenuEntry);
            MenuEntries.Add(fullScreenMenuEntry);
            MenuEntries.Add(speedMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }

        void SetMenuEntryText()
        {
            ungulateMenuEntry.Text = "Preferred ungulate: " + currentUngulate;
            languageMenuEntry.Text = "Language: " + languages[currentLanguage];
            fullScreenMenuEntry.Text = "FullScreen: " + (fullscreen ? "on" : "off");
            speedMenuEntry.Text = "Speed: " + speed;
        }

        #endregion

        #region Handle Input

        void UngulateMenuEntrySelected(object sender, XNAPlayerIndexEventArgs e)
        {
            currentUngulate++;

            if (currentUngulate > Ungulate.Llama)
                currentUngulate = 0;

            SetMenuEntryText();
        }

        void LanguageMenuEntrySelected(object sender, XNAPlayerIndexEventArgs e)
        {
            currentLanguage = (currentLanguage + 1) % languages.Length;
            SetMenuEntryText();
        }

        void fullScreenMenuEntrySelected(object sender, XNAPlayerIndexEventArgs e)
        {
            fullscreen = !fullscreen;
            SetMenuEntryText();
        }

        void speedMenuEntrySelected(object sender, XNAPlayerIndexEventArgs e)
        {
            speed++;
            SetMenuEntryText();
        }

        #endregion
    }
}
